#include<iostream>
using namespace std;
int Day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check_date(int date)
{
    int year=date/10000;
    int month=date%10000/100;
    int day=date%100;

    if(month!=2&&day>Day[month]||day<=0)return false;
    if(month<=0||month>12)return false;
    int leap=0;
    int res=0;
    if(month==2)
    {
        if(year%100!=0&&year%4==0 || year%400==0)
            {
                if(day>29)return false;
            }
        else if(day>28) return false;

    }
    return true;


}
int main()
{
    int date1,date2;
    int res=0;
    cin>>date1>>date2;
    for(int i=1000;i<10000;i++)
    {
        int date =i,x=i;
        while(x)
        {
            date=date*10+x%10;
            x/=10;
        }
        if(date1<=date&&date<=date2)
        {
            if(check_date(date))res++;
        }
    }
    cout<<res<<endl;
}